
<div class='_line'></div>
<div class='_line'></div>
<div class='_cut'></div>
<div class='_line'></div>
<div id='content'>
<div id='contents'>
    <?php foreach($coupons as $k=>$v){ ?>
    <?php if($k%3==0){?>
<div class='row'> 
    
        <?php }?>
        <div class='col-sm-3 col-md-4' >
        <div class="thumbnail" style="margin-bottom:10px;">
            <div class='caption _ling2'>
                <div class='_ling_div' style='margin-left:3.5rem;padding:11px;' >
                <div>
                    <span>手机号：<?php echo $v['client_id']['mobile'];?></span>
                </div>
                <div>
                    <span>识别码：<?php echo $v['number'];?></span>
                </div>
                <div>
                    <span>劵别：<?php echo $v['coupon_id']['content'],$v['coupon_id']['type_name'];?></span>
                </div>
                <div>
                    <span>过期时间：<?php echo date('Y-m-d',$v['coupon_id']['end_time']);?></span>
                </div>
                <div>
                    <span>状态：<?php if($v['status']==0 && $v['coupon_id']['end_time']>time()){ echo '未使用';}elseif($v['status']==0 && $v['coupon_id']['end_time']<time()){ echo '已过期'; }?></span>
                </div>
                <div >
                    <span style='word-break:normal; width:auto; display:block; white-space:pre-wrap;word-wrap : break-word ;overflow: hidden ;' >说明：<?php echo $v['coupon_id']['intro']; ?></span>
                </div>
                </div>
            </div> 
        </div>       
    </div>
    <?php if(($k+1)%3==0 || $coupons[$k+1]['id']<1){?>
</div>
    <?php } ?>
    <?php } ?>

</div>
<script type='text/javascript'>
    var number = 12;
    function  loaddata()
    {
        if(number ==-1){
            return;
        }
        totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());

        if ($(document).height() <= totalheight)
        {
            $.ajax({ url: "/user/coupon/append?store_id=<?php echo (int)$_GET['store_id'];?>&start="+number,async:true, success: function(msg){
                    if(msg == 'false'){
                        number = -1;
                        return ;
                    }
                    var html = "";
                    msg = eval('(' + msg + ')');
                    $.each(msg,function(i,v){
                        if(i%4==0){
                            html += "<div class='row'>";
                        }
                        html += "<div class='col-sm-3 col-md-4'>";
                        html += '<div class="thumbnail" style="margin-bottom:10px">';
                        html += "<div class='caption _ling2'>";
                        html += "<div class='_ling_div' style='margin-left:3.5rem;padding:11px;' >";
                        html += "<div><span>手机号：";
                        html += v.client_id.mobile==null?'':v.client_id.mobile;
                        html += "</span></div>";
                        html += "<div><span>识别码：";
                        html += v.number==null?'':v.number;
                        html += "</span></div>";
                        html += "<div><span>劵别：";
                        html += v.coupon_id.content==null?'':v.coupon_id.content;
                        html += v.coupon_id.type_name==null?'':v.coupon_id.type_name;
                        html += "</span></div>";
                        html += "<div><span>过期时间：";
                         
                         var end_time = UnixToDate(v.coupon_id.end_time,8);
                         var time = "<?php echo time(); ?>";
                        html += end_time==null?0:end_time;
                        html += "</span></div>";
                        html += "<div><span>状态：";
                        
                        if(v.status==0 && v.coupon_id.end_time<time){
                            html +='已过期';
                        }else{
                            html += v.status==0?'未使用':v.status;
                        }
                        html += "</span></div>";
                        html += "<div ><span style='word-break:normal; width:auto; display:block; white-space:pre-wrap;word-wrap : break-word ;overflow: hidden ;' >说明：";
                        html += v.coupon_id.intro;
                        html += "</span></div>";
                        html += "</div></div></div></div>";
                        if((i+1)%3==0){
                            html += "</div>";
                        }
                        number += 1;
                    });
                    $('#contents').append(html);
            }});
                // /$("#container").append(text);
        }
    }

    $(window).scroll(function () {
        loaddata();
    });
</script>
<script type="text/javascript">
    function href(){
        var store_id = <?php echo $_GET['store_id'];?>;
        window.location.href="/user/coupon/check?store_id="+store_id;
    }

    function UnixToDate(unixTime,timeZone) {
        if (typeof (timeZone) == 'number')
        {
          unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
        }
        var time = new Date(unixTime * 1000);
        var ymdhis = "";
        ymdhis += time.getUTCFullYear() + "-";
        ymdhis += (time.getUTCMonth()+1) + "-";
        ymdhis += time.getUTCDate();
        //ymdhis += " " + time.getUTCHours() + ":";
        //ymdhis += time.getUTCMinutes() + ":";
        //ymdhis += time.getUTCSeconds();

        return ymdhis;
    }
</script>

